package game;

import edu.monash.fit2099.engine.displays.Display;
import edu.monash.fit2099.engine.positions.DefaultGroundCreator;
import edu.monash.fit2099.engine.positions.GameMap;
import edu.monash.fit2099.engine.positions.World;
import game.actors.Bear;
import game.actors.Player;
import game.actors.Wolf;
import game.grounds.AppleTree;
import game.grounds.HazelnutTree;
import game.grounds.YewBerryTree;
import game.items.Bedroll;
import game.items.Bottle;
import game.actors.Deer;

import java.util.Arrays;
import java.util.List;

public class Earth extends World {
    public Earth(Display display) {
        super(display);
    }

    public void constructWorld() throws Exception {
        DefaultGroundCreator groundCreator = new DefaultGroundCreator();
        groundCreator.registerGround('.', Snow::new);

        List<String> map = Arrays.asList(
                "........................................",
                "........................................",
                "........................................",
                "........................................",
                "........................................",
                "........................................",
                "........................................",
                "........................................",
                "........................................",
                "........................................"
        );

        GameMap gameMap = new GameMap("Forest", groundCreator, map);
        this.addGameMap(gameMap);

        Player player = new Player("玩家", 'ඞ', 100);
        this.addPlayer(player, gameMap.at(1, 1));

        // 背包里添加睡袋和水瓶
        player.addItemToInventory(new Bedroll());
        player.addItemToInventory(new Bottle());

        // 玩家获得攻击能力（这样动物会在玩家周围暴露 AttackAction）
        player.enableAbility(Abilities.CAN_ATTACK);

        // 地图上增加动物
        gameMap.addActor(new Deer(), gameMap.at(5, 5));
        gameMap.addActor(new Wolf(), gameMap.at(8, 6));
        gameMap.addActor(new Bear(), gameMap.at(12, 8));

        // 在地图指定坐标种树（T/A/Y）
        gameMap.at(6, 4).setGround(new AppleTree());
        gameMap.at(10, 7).setGround(new HazelnutTree());
        gameMap.at(14, 5).setGround(new YewBerryTree());
    }
}
